package com.salesmanager.core.modules.jms.service;

import com.salesmanager.core.modules.jms.JmsMessageType;
import com.salesmanager.core.modules.jms.process.JmsProducer;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * Created by Liutong on 11/3/15.
 */
@Service("jmsService")
public class JmsServiceImpl implements JmsService {

    @Autowired
    private JmsProducer jmsProducer;

    @Autowired
    private ActiveMQQueue outLogQueue;

    @Autowired
    private ActiveMQQueue customerActionQueue;

    @Autowired
    private ActiveMQQueue cacheUpdateQueue;

    @Autowired
    private ActiveMQQueue dataReportQueue;


    @Override
    public void sendMessage(JmsMessageType jmsMessageType,String message) {
        switch (jmsMessageType){
            //out 日志
            case OUT_LOG: jmsProducer.sendMessage(outLogQueue,message); break;
            //用户行为日志
            case CUSTOMER_ACTION_LOG: jmsProducer.sendMessage(customerActionQueue,message);break;
            //更新Redis缓存数据
            case REDIS_CACHE_UPDATE: jmsProducer.sendMessage(cacheUpdateQueue,message);
            //数据报告消息
            case DATA_REPORT : jmsProducer.sendMessage(dataReportQueue,message);
        }
    }

}
